package org.itheima.googleplay.http;

import org.itheima.googleplay.bean.HomeBean;
import org.itheima.googleplay.ui.fragment.LoadingPager.LoadedResult;
import org.itheima.googleplay.utils.LogUtils;

import com.google.gson.Gson;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseStream;
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;

/**
 * @包名: org.itheima.googleplay.http
 * @类名: HomeProtocol
 * @作者: 肖琦
 * @创建时间 : 2015-3-22 上午11:20:27
 * 
 * @描述: TODO
 * 
 * @SVN版本: $Rev: 12 $
 * @更新人: $Author: xq $
 * @更新时间: $Date: 2015-03-22 16:33:25 +0800 (星期日, 22 三月 2015) $
 * 
 * @更新描述:
 */
public class HomeProtocol extends BaseProtocol<HomeBean>
{

	@Override
	protected String getKey()
	{
		return "home";
	}

	@Override
	protected HomeBean parseJson(String json)
	{
		Gson gson = new Gson();
		return gson.fromJson(json, HomeBean.class);
	}

	// public HomeBean loadData(int index) throws Exception
	// {
	// HttpUtils utils = new HttpUtils();
	// String url = "http://10.0.2.2:8080/GooglePlayServer/home";
	//
	// RequestParams params = new RequestParams();
	// params.addQueryStringParameter("index", index + "");
	//
	// ResponseStream stream = utils.sendSync(HttpMethod.GET, url, params);
	//
	// int statusCode = stream.getStatusCode();
	// if (200 == statusCode)
	// {
	// // 正确返回
	// String json = stream.readString();
	// LogUtils.d(json);
	//
	// // 解析json
	// Gson gson = new Gson();
	// return gson.fromJson(json, HomeBean.class);
	// }
	// throw new RuntimeException("服务器连接异常");
	// }
}
